#!/usr/bin/env python
# -*- conding:utf-8 -*-
import argparse
import time
import sys
if __name__ == '__main__':
    # 创建对象
    parser = argparse.ArgumentParser()
    # 添加参数
    parser.add_argument('--period', action='store_true')
    parser.add_argument('--excel-path', required=True, help='path of excel')
    parser.add_argument('--date', default=time.strftime('%Y-%m-%d', time.localtime(time.time())),
                        help='datetime in format: %Y-%m-%d')
    parser.add_argument(
        '--excel-dir', required='--period' in sys.argv, help='directory of excel files.')
    # 解析参数
    args = parser.parse_args()
    print('--period' in sys.argv)
    print(sys.argv)
    print(args.period is False)
    print(args.excel_path)
    print(args.date)

# 命令行执行：
# python .\analyseSum.py --excel-path  C:\Users\vainuer\Desktop\Test\test\test.xlsx
# python .\analyseSum.py --period --excel-path  C:\Users\vainuer\Desktop\Test\test --excel-dir C:\Users\vainuer\Desktop\Test\test
# python .\analyseSum.py --excel-path  C:\Users\vainuer\Desktop\Test\test\test.xlsx --date 2021-10-10
